home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Essential Home & Business Collection
/
The Essential Home & Business Collection.iso
/
26
/
3
/
4
/
PORT4.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-11-11
|
4KB
|
155 lines
'Program Name : Port4.bas
'Author : Lloyd L. Smith for Spectra Technical Support
'Date : 11-12-90
'Compuserve # : GO PCVENB, Vendor #12/Spectra, Tech Support ID 71530,2640
'Tech Support BBS: 813-625-1721, PC-Board, 8,N,1 USR HST 300 - 14.4, 24hrs
'Tech Support Fax: 813-625-1698 G2 & G3 compatible
'Tech Support Voc: 813-625-1172 Voice
'Prog ConceptDate: 07-01-88 - Smithtronix Corporation
'
'Basic Serial Port routines for extended com ports, illustrates polled use
'of serial ports before PowerBasic 2.10a. Use subroutines as needed. These
'are programming examples.
'
'Remember if you use polled ports, they are not interrupt driven nor buffered.
'With PB 2.1a you now have access to 4 interrupt driven & buffered serial ports.
'
'Serial Port Base Address Information
'these addresses vary, be sure to check the board you are using.
'com1 3f8-3ff ,com2 2f8-2ff ,com3 3e8-3ef ,com4 3e0-3e7
'com5 2f0-2f7 ,com6 2e8-2e7 ,com7 2e0-2e7 ,com8 260-267
'
'Serial Port Address Register LineUp
'3F8H (Out) Data Output to transmitter holding register
'3F8H (In) Data Input from receive Data Register
'3F9H (Out) Baud-Rate Divisor(Low Byte)
'3F9H (In) Baud-Rate Divisor(High Byte)
'3FAH (In) Interrupt Enable Register
'3FBH (Out) Line Control Register
'3FCH (Out) Modem Control Register
'3FDH (In) Line Status Register
'3FEH (In) Modem Status Register
Xmitcom3:
def seg= &H40
Ckt3stat:
address=&h3E8
x=inp(address+5)
if x and 32 then gosub xmitcom3 else Ckt3stat
xmitcom3:
out Port3,DataO3$
def seg
return
RecCom3:
def seg= &H40
ckr3stat:
address=&h3E8
x=inp(address+5)
if x and 1 then gosub RecCom3 else ckr3stat
reccom3:
datai3$=inp(address)
def seg
return
Xmitcom4:
def seg= &H40
ck4stat:
address=&h3E0
x=inp(address+5)
if x and 32 then gosub xmitcom4 else ck4stat
xmitcom4:
out port4,dataO4$
def seg
return
RecCom4:
def seg= &H40
ckr4stat:
address=&h3E0
x=inp(address+5)
if x and 1 then gosub RecCom4 else ckr4stat
reccom4:
datai4$=inp(address)
def seg
return
'This routine swaps the base addresses of com1 & com2
SWapCom12:
defseg=&H40
x=peek(0):y=peek(1)
poke 0,peek(2):poke1,peek(3)
poke 2,x:poke 3,y
def seg
SetBaudRate:
'Setup the serial port baud rate the hardway
'Additional register programming available from intel 8250 data books.
base=&H3F0
addr=base+3
out addr,&H80 'turn on the seventh high bit
out addr-2,0 'msb for 1200 baud
out addr-3,&h60 'lsb for 1200 baud
'setting up the number of start and stop bits for serial port control
a=0
a=a or &H02
out base+3,27
out base+5,0 'disable interrupts
return
'this routine swaps the port addresses to trick dos into going
'to more than one one port. Only two serial ports can be open at any
'one time.
setport:
close #1
def seg=&H40
basel=&HF8:baseh=&H3
poke 0,basel
poke 1, baseh
def seg
OPEN "com1:9600,n,8,1,RS,CD,DS,CS,OP1000,RB2000" FOR RANDOM AS #1
return
Comset4PortsLow:
'com1 3f8-3ff ,com2 2f8-2ff ,com3 3e8-3ef ,com4 3e0-3e7
def seg=&h40
poke 0,&f8 'com1 set low byte
poke 1,&h3 'com1 set hi byte
poke 2,&f8 'com2 set low byte
poke 3,&h2 'com2 set hi byte
poke 4,&e8 'com3 set low byte
poke 5,&h3 'com3 set hi byte
poke 6,&e0 'com4 set low byte
poke 7,&h3 'com4 set hi byte
def seg
return
Comset4PortsHi:
'com5 2f0-2f7 ,com6 2e8-2e7 ,com7 2e0-2e7 ,com8 260-267
def seg=&h40
poke 0,&f0 'com1 set low byte
poke 1,&h2 'com1 set hi byte
poke 2,&e8 'com2 set low byte
poke 3,&h2 'com2 set hi byte
poke 4,&e0 'com3 set low byte
poke 5,&h2 'com3 set hi byte
poke 6,&60 'com4 set low byte
poke 7,&h2 'com4 set hi byte
def seg
return